﻿using MediatR;
using S.Services.SheepMale.Api.Application.Command.SheepMaleCommand;
using S.Services.SheepMale.Domain.PurchaseSales;
using S.Services.SheepMale.Infrastructure;

namespace S.Services.SheepMale.Api.Application.CommandHandler.SheepMaleCommandHandler
{
    public class SheepFatherDelCommandHandler : IRequestHandler<SheepFatherDelCommand, int>
    {
        private readonly IRepository<SheepMaleInfo> repository;

        public SheepFatherDelCommandHandler(IRepository<SheepMaleInfo> repository)
        {
            this.repository = repository;
        }

        public async Task<int> Handle(SheepFatherDelCommand request, CancellationToken cancellationToken)
        {
            return await repository.DeleteAllAsync(x => x.MaleId == request.maleId);
        }
    }
}
